package com.flyoil.petromp.view;

import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.flyoil.petromp.R;

/**
 * Created by songzhiyin on 2017/10/30.
 * 工单详情界面，底部的自定义签字控件
 */

public class SignatureTopView extends LinearLayout {
    private Context mContext;
    private View view;
    private LinearLayout line_edt;
    private TextView tv_agree, tv_unAgree;

    public SignatureTopView(Context context) {
        super(context);
        initview(context);
    }

    public SignatureTopView(Context context, @Nullable AttributeSet attrs) {
        super(context, attrs);
        initview(context);
    }

    public SignatureTopView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        initview(context);
    }

    private void initview(Context context) {
        this.mContext = context;
        view = LayoutInflater.from(context).inflate(R.layout.view_message_signature_layout, this);
        line_edt = view.findViewById(R.id.line_view_message_signature_edt);
        tv_agree = view.findViewById(R.id.tv_view_message_signature_agree);
        tv_unAgree = view.findViewById(R.id.tv_view_message_signature_unagree);
    }

    /**
     * 设置批准按钮的点击事件
     *
     * @param onclockListener
     */
    public void setAgreeOnclockListener(View.OnClickListener onclockListener) {
        if (tv_agree != null && onclockListener != null) {
            tv_agree.setOnClickListener(onclockListener);
        }
    }

    /**
     * 设置退回按钮和输入框的点击事件
     *
     * @param onclockListener
     */
    public void setUnAgreeOnclockListener(View.OnClickListener onclockListener) {
        if (tv_unAgree != null && onclockListener != null) {
            tv_unAgree.setOnClickListener(onclockListener);
        }
        if (line_edt != null && onclockListener != null) {
            line_edt.setOnClickListener(onclockListener);
        }
    }

}
